﻿using RecruitmentPage.Models.RPModel;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using System.Web;

namespace RecruitmentPage.Models
{
    public class RPContext : DbContext
    {
        public RPContext()
            : base("RPDb")
        {
            Database.SetInitializer(new RPDatabaseInitializer());
        }
        public DbSet<Account> Account { get; set; }
        DbSet<Industry> Industry { get; set; }

        DbSet<Job> Job { get; set; }
        DbSet<Location> Location { get; set; }
        public DbSet<Menu> Menu { get; set; }
        public DbSet<JobLevel> JobLevel { get; set; }
        public DbSet<JobType> JobType { get; set; }
        public DbSet<CareerExpect> CareerExpect { get; set; }

        public DbSet<Education> Education { get; set; }
        public DbSet<Major> Major { get; set; }
        public DbSet<KindofDegree> KindofDegree { get; set; }
        public DbSet<Degree> Degree { get; set; }

        public DbSet<University> University { get; set; }

        public DbSet<PersonalInfor> PersonalInfor { get; set; }
        public DbSet<Role> Role { get; set; }
        public DbSet<RoleMenu> RoleMenu { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            //modelBuilder.Entity<PersonalInfor>()
            //.HasMany(p => p.Jobs)
            //.WithRequired()
            //.HasForeignKey(c => c.UniqueId)
            //.WillCascadeOnDelete(false);
            modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
        }
    }
}